<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>节流</title>
</head>
<body>
<label>
    <input type="text">
</label>

<script>
    document.querySelector("input").addEventListener('input',throttle(function () {
        console.log("asd")
    },500))

    function throttle(fn,delay) {
        let time1 = new Date();
        return function (params) {
            let time2 = new Date();
            if( ( time2 - time1 ) > delay ){
                time1 = new Date();
                fn.apply(this,params)
            }
        }
    }

</script>
</body>
</html>